{
  "properties" : { },
  "id" : "61c3d25497e34a6ab084931b66921ec5",
  "script" : null,
  "groupId" : "e7c57e1086a64d09a8c9d615ca57f6fd",
  "name" : "下载配置信息",
  "createTime" : 1727071188093,
  "updateTime" : 1726650325166,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "export",
  "method" : "GET",
  "parameters" : [ {
    "name" : "id",
    "value" : "1801438832302784514",
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : null,
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import java.lang.StringBuffer;
import response;
import java.util.stream.Collectors;
import com.kd.ndmp.core.excel.NetDeviceCfgFileVO
import org.springframework.beans.BeanUtils;
import java.io.BufferedOutputStream;
import javax.servlet.ServletOutputStream;

ids = id.split(",");
sql = """ select * from ndmp_net_device_cfg_file where id in 
    <foreach collection="ids" open="(" separator="," close=")" item="item">
        #{item}
    </foreach>
    order by update_time desc
    limit 10
"""
list = db.select(sql).stream().map(result -> {
    NetDeviceCfgFileVO netDeviceCfgFileVO = new NetDeviceCfgFileVO();
    BeanUtils.copyProperties(result, netDeviceCfgFileVO);
    file = result.file;
    String content = new String(file);
    netDeviceCfgFileVO.setContent(content);
    return netDeviceCfgFileVO;
}).collect(Collectors.toList());
//拼接字符串
StringBuffer text = new StringBuffer();
for (log in list) {
    text.append(log.getContent());
    text.append("\r\n");//换行字符
}

// response.setCharacterEncoding("utf-8");
//设置响应的内容类型
// response.setContentType("text/plain");
//设置文件的名称和格式
response.setHeader("Content-Disposition", "attachment;filename=startup.txt");
BufferedOutputStream buff = null;
ServletOutputStream outStr = null;
try {
    outStr = response.getOutputStream();
    buff = new BufferedOutputStream(outStr);
    buff.write(text.toString().getBytes("UTF-8"));
    buff.flush();
    buff.close();
} catch (e) {
    log.error("exportCfg is error:{}", e);
} finally {
    try {
        buff.close();
        outStr.close();
    } catch (e) {
        log.error("close buff is error:{}", e);
    }
}
